use cmsis_rtos2_rs::{os_delay, static_mem::{Task, Thread}};

use super::driver::{ctrl, sensor};



struct DrainTask;
static THREAD: Thread<1024> = Thread::uninit();

pub unsafe fn start() {
    THREAD.spawn(&DrainTask);
}

impl Task for DrainTask {

    fn run(&self) {
        
        loop {
            if sensor::is_waste_checked() {
                ctrl::drain_pump_open();
            } else {
                ctrl::drain_pump_close();
            }

            os_delay(500);
        }
    }
}
